<template>
  <div v-if="deletable" class="node-delete-layer">
    <zh-button type="danger" @click="delNode(node, callback)">删除</zh-button>
    <zh-button @click="onCancel">取消</zh-button>
  </div>
</template>
<script lang="ts" setup name="ServiceDeleteConfirm">
// 定义子组件向父组件传值/事件
const emit = defineEmits(['callback','update:modelValue']);
//------------------接收传入参数------------------------
const props = defineProps({
	modelValue: {
    type: Boolean,
    default: false,
  },
  node: {
    type: Object,
    default: function() {
      return {};
    },
  },
});
// 定义子组件向父组件传值/事件
const deletable=ref(props.modelValue);
watch(
  () => props.modelValue,
  (val: any) => {
    deletable.value=val
  },
  {
    deep: true,
  }
);

/**
     * 删除节点
     * @param {*} node
     * @param {*} fun
     */
const delNode=(node, fun)=>{
  $store.serviceFlow.DEL_NODE(node);
  // 回调
  if (fun) {
    fun(node);
  }
}
const callback=()=> {
  emit('callback');
}
const onCancel=()=>{
  
  deletable.value = false
  emit('update:modelValue',deletable.value)
}
</script>
